<template>
	<view>
		<web-view @message="handlePostMessage" :src="url"></web-view>
	</view>
</template>

<script>
	export default {
		props: ["purl"],
		data() {
			return {
				url: `https://test.gluz.com.cn/#/?token=5c14f019-8a18-49c9-a74a-c87cd283197b&user_id=1633&lang=zh&version=2.6.0&app=1`
			}
		},
		onLoad(options, title) {
			if (this.purl) this.url = purl
			if (options.url) this.url = options.url
			if (options.title) {
				uni.setNavigationBarTitle({
					title
				})
			}
		},
		methods: {
			handlePostMessage(e) {
				console.log("===================收到消息===================")
				const {
					action,
					data,
					title
				} = e.detail.data[0]
				console.log(e)
				console.log(action, data)
				if (action == "navigateTo") {
					uni.navigateTo({
						url: "/pages/zWebView/zWebView?title=" + title + "&url=" + data
					})
				}
				// uni.navigateBack()
			}
		}
	}
</script>